[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
gcvt() Convert Double to String
#include <stdlib.h> Required for declarations only
char *gcvt(value,ndec,buffer);
double value; Value to be converted
int ndec; Number of significant digits stored
char *buffer; Storage location for results
gcvt() converts the double 'value' to a character string and stores
it in 'buffer'. 'buffer' should be large enough to store 'value'
plus a terminating null character ('\0'), which is automatically
appended. gcvt() attempts to produce 'ndec' significant digits in
FORTRAN F format or, if unsuccessful, FORTRAN E format. Trailing
zeros may be suppressed. There is no provision for overflow.
Returns: A pointer to the string of digits. There is no error
return.
-------------------------------- Example ---------------------------------
The following example converts a double value to a string and prints
it out.
#include <stdlib.h>
char buffr[30];
int declen = 6;
main()
{
gcvt(12.9842,declen,buffr);
printf("value: %s\n",buffr);
}
See Also:
atof()
atoi()
atol()
ecvt()
fcvt()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson